// 地址管理

import { request } from '@/utils/request'
import type { AddressItem, AddressParams } from '@/types/address'

//获取收货地址列表
export const getMemberAddressAPI = () => {
  return request<AddressItem[]>({
    url: '/member/address',
  })
}

// 添加收货地址
export const postMemberAddressAPI = (data: AddressParams) => {
  return request({
    url: '/member/address',
    method: 'POST',
    data,
  })
}

// 获取收货地址详情
export const getMemberAddressDetailAPI = (id: string) => {
  return request<AddressItem>({
    url: `/member/address/${id}`,
  })
}

// 修改收货地址
export const putMemberAddressAPI = (id: string, data: AddressParams) => {
  return request({
    url: `/member/address/${id}`,
    method: 'PUT',
    data,
  })
}

// 删除收货地址
export const deleteMemberAddressAPI = (id: string) => {
  return request({
    url: `/member/address/${id}`,
    method: 'DELETE',
  })
}
